<?php if (!defined('THINK_PATH')) exit();?><style>
    body {
        background-color: #E0ECFF;
    }
    .lbj{
        border: 1px solid #e6e9ece6;
    }

    .lbj th{
        background-color: #e0ecff45;
        text-align: center;
    }
    .lbj td{
        height: 30px;
        font-size: 12px;
        padding: 3px;
    }

    .ggdtable {
        width: 98%;
        /* height: 306px; */
        border: 2px solid;
        margin: 8px 2px 2px 8px;
        padding: 10px 10px 10px 15px;
        background-color: #FFFFFF;
    }

    .ggdtable td {
        /*border: 1px solid;*/
    }

    .ggdtable th , .qianshou th{
        background-color: #e0ecff45;
        text-align: center;
        height: 30px;
    }

    .sqzk {
        font-size: 18px;
        color: #005595;
        font-weight: bold;
        padding-top: 5px;
    }

    .logo {
        width: 25px;
        align-content: center;
        padding: 4px;
    }

    .bt {
        font-size: 16px;
    }
    .ggd_title{
        text-indent: 2em;
        font-size: 14px;
        padding-bottom: 5px;
    }
    .liucheng{
        width: 100%;
        border: none;
    }
    .liucheng td{
        width: 25%;
        border: none;
        height: 28px;
        padding: 5px;
        font-size: 14px;
    }
    .qianshou{
        width: 100%;
        border: none;
    }
    .qianshou td{
        height: 28px;
        padding: 5px;
        text-align: center;


    }
</style>
<link rel="stylesheet" type="text/css" media="print2" href="/solve/Public/css/myJqPrint_ggd.css" />


<div data-options="fit:true">
    <div data-options="region:'center',title:''" style="padding:5px;background:#e0ecff99;">
        <div id="view_tool" style="background-color: #E0ECFF;border-bottom: 1px solid #95B8E7;margin: -5px;">
            <table>
                <tr>

                    <td>

                        <?php if($index == 'editor'): ?><a href="#" class="easyui-linkbutton" onclick='ok_lsggd("<?php echo ($id); ?>",2)'
                               data-options="iconCls:'icon-standard-accept',plain:true">发布</a><?php endif; ?>

                        <?php if($index == 'checker'): ?><a href="#" class="easyui-linkbutton" onclick='ok_lsggd("<?php echo ($id); ?>",3)'
                               data-options="iconCls:'icon-standard-folder-page',plain:true">校对</a><?php endif; ?>

                        <?php if($index == 'examine'): ?><a href="#" class="easyui-linkbutton" onclick='ok_lsggd("<?php echo ($id); ?>",4)'
                               data-options="iconCls:'icon-standard-page-white-delete',plain:true">审核</a><?php endif; ?>
                        <?php if($index == 'approve'): ?><a href="#" class="easyui-linkbutton" onclick='ok_lsggd("<?php echo ($id); ?>",5)'
                               data-options="iconCls:'icon-standard-application-edit',plain:true">批准</a><?php endif; ?>

                    </td>
                    <td>
                        <div class="datagrid-btn-separator"></div>
                    </td>

                    <td>
                        <?php if((in_array('22',explode(',',$_SESSION['group_id']))) AND (in_array('装配车间',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("装配车间")' data-options="iconCls:'icon-standard-accept',plain:true">装配签收</a><?php endif; ?>
                        <?php if((in_array('23',explode(',',$_SESSION['group_id']))) AND (in_array('内饰车间',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("内饰车间")' data-options="iconCls:'icon-standard-accept',plain:true">内饰签收</a><?php endif; ?>
                        <?php if((in_array('24',explode(',',$_SESSION['group_id']))) AND (in_array('调试车间',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("调试车间")' data-options="iconCls:'icon-standard-accept',plain:true">调试签收</a><?php endif; ?>
                        <?php if((in_array('25',explode(',',$_SESSION['group_id']))) AND (in_array('试制车间',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("试制车间")' data-options="iconCls:'icon-standard-accept',plain:true">试制签收</a><?php endif; ?>
                        <?php if((in_array('26',explode(',',$_SESSION['group_id']))) AND (in_array('质检科',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("质检科")' data-options="iconCls:'icon-standard-accept',plain:true">质检签收</a><?php endif; ?>
                        <?php if((in_array('27',explode(',',$_SESSION['group_id']))) AND (in_array('物料科',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("物料科")' data-options="iconCls:'icon-standard-accept',plain:true">物料签收</a><?php endif; ?>
                        <?php if((in_array('28',explode(',',$_SESSION['group_id']))) AND (in_array('生产科',$bmname))): ?><a href="#"  class="easyui-linkbutton"  onclick='qianshou("生产科")' data-options="iconCls:'icon-standard-accept',plain:true">生产签收</a><?php endif; ?>
                    </td>
                    <td>
                        <div class="datagrid-btn-separator"></div>
                    </td>

                        <td>
                            <a href="#" class="easyui-linkbutton" onclick='out_ggd_excel("<?php echo ($id); ?>","<?php echo ($data[state]); ?>")'
                               data-options="iconCls:'icon-standard-table-save',plain:true">导出excel</a>
                            <a href="#" class="easyui-linkbutton" onclick='print_lsggd()'
                               data-options="iconCls:'icon-standard-table-save',plain:true">打印</a>
                            <!--是否能够打印以状态确定，用js message显示-->

                        </td>
                        <td>
                            <div class="datagrid-btn-separator"></div>
                        </td>



                    </td>

                    <td>
                        <a href="#" class="easyui-linkbutton" onclick="backgo('<?php echo ($index); ?>')"
                           data-options="iconCls:'icon-back',plain:true">返回</a>
                    </td>
                </tr>
            </table>

        </div>


        <table id="ggdtable" class="ggdtable" border="1" cellspacing="0">
            <tr>
                <th width="150">
                    <div>
                        <image class="logo" src="/solve/Public/images/sqlogo.jpg" style="float: left"/>
                        <div class="sqzk" style="float: left">陕 西 重 汽</div>
                    </div>
                </th>
                <th rowspan="2" class="bt">工艺文件更改通知单（临时）</th>
                <th width="100">更改原因</th>
                <td width="100" style="text-align:center">
                    <?php if($reason == 'SJ' ): ?>设计更改
                        <?php else: ?>
                        工艺更改<?php endif; ?>
                </td>
                <th width="120">更改单编号</th>
                <td id="ggdids" width="150" style="text-align:center"><?php echo ($data['ids']); ?></td>
            </tr>
            <tr>
                <th>

                    陕汽乌海专用汽车有限公司
                </th>
                <th>实施日期</th>
                <td  width="100" height="35" style="text-align:center"><?php echo (substr($data['pzdate'],0,10)); ?></td>
                <td colspan="2" rowspan="3" style="vertical-align: top;">
                  <table class="qianshou" border="1" cellspacing="0">
                        <tr>
                            <th style="border-top: none;border-left: none;">发往单位</th>
                            <th style="border-top: none;border-right: none;">签名/日期</th>
                        </tr>
                        <tr>
                            <?php if(is_array($lsggdqsdata)): $i = 0; $__LIST__ = $lsggdqsdata;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
                            <td style="border-left: none;" width="75"><?php echo ($vo["bmname"]); ?></td>
                            <td style="border-right: none;"  id="<?php echo ($vo["bmname"]); ?>_qs"><?php echo ($vo["qsname"]); ?>  <?php echo (substr($vo["qstime"],0,10)); ?></td>
                        </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                        </tr>
                    </table>


                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding:5px;"><p>&nbsp;</p>
                    <p class="ggd_title">
                        <?php echo ($header); ?>
                    </p>
                    <p class="ggd_title">
                         <b style="font-size: 14px;">说明：</b><?php echo ($data['sm']); ?>
                    </p>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding:5px;">

                    <?php if(count($zjlbj) > 0 ): ?><p style="padding-top:8px"><b>增加零件如下：</b></p>
                        <table class="lbj" border="1" cellspacing="0">
                            <tr>
                                <th width="50">工位</th>
                                <th width="200">图号</th>
                                <th width="200">名称</th>
                                <th width="50">数量</th>
                                <th width="200">库存处理意见</th>
                                <th width="200">备注</th>
                            </tr>
                            <?php if(is_array($zjlbj)): $i = 0; $__LIST__ = $zjlbj;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
                                    <td style="text-align: center"><?php echo ($vo["gw"]); ?></td>
                                    <td><?php echo ($vo["ljh"]); ?></td>
                                    <td><?php echo ($vo["mc"]); ?></td>
                                    <td style="text-align: center"><?php echo ($vo["sl"]); ?></td>
                                    <td><?php echo ($vo["kc"]); ?></td>
                                    <td><?php echo ($vo["bz"]); ?></td>

                                </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                        </table>
                        <?php else: ?>
                        <p style="padding-top:8px"><b>无增加零件!</b></p><?php endif; ?>


                    <?php if(count($jslbj) > 0 ): ?><p style="padding-top:8px"><b>减少零件如下：</b></p>
                        <table class="lbj" border="1" cellspacing="0">
                            <tr>
                                <th width="50">工位</th>
                                <th width="200">图号</th>
                                <th width="200">名称</th>
                                <th width="50">数量</th>
                                <th width="200">库存处理意见</th>
                                <th width="200">备注</th>
                            </tr>
                            <?php if(is_array($jslbj)): $i = 0; $__LIST__ = $jslbj;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
                                    <td style="text-align: center"><?php echo ($vo["gw"]); ?></td>
                                    <td><?php echo ($vo["ljh"]); ?></td>
                                    <td><?php echo ($vo["mc"]); ?></td>
                                    <td><?php echo ($vo["sl"]); ?></td>
                                    <td><?php echo ($vo["kc"]); ?></td>
                                    <td><?php echo ($vo["bz"]); ?></td>

                                </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                        </table>
                        <?php else: ?>
                        <p style="padding-top:8px"><b>无减少零件!</b></p><?php endif; ?>
                    <p style="padding-top:8px"><b><?php echo ($data['part_sm']); ?></b></p>

                    <?php if(count($fjs) > 0 ): ?><b>附件：</b>

                        <?php if(is_array($fjs)): $i = 0; $__LIST__ = $fjs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><a style="padding-left: 5px;" href="http://192.168.8.200/solve/public<?php echo ($vo["savepath"]); ?>"
                               target="_blank"><?php echo ($vo["name"]); ?></a><?php endforeach; endif; else: echo "" ;endif; endif; ?>
            </tr>
            <tr>
                <td colspan="6">
                    <table class="liucheng" border="1" cellspacing="0">
                        <tr>
                            <td>编制：<?php echo ($data['nickname']); ?>  <?php echo (substr($data['publishtime'],0,10)); ?></td>
                            <td id="jd_show">
                                校对：
                                <?php if($data['jddate'] != '' ): echo ($data['jdname']); ?>  <?php echo (substr($data['jddate'],0,10)); endif; ?>
                            </td>
                            <td id="sh_show">审核：
                                <?php if($data['shdate'] != '' ): echo ($data['shname']); ?>  <?php echo (substr($data['shdate'],0,10)); endif; ?>
                            </td>
                            <td id="pz_show">批准：
                                <?php if($data['pzdate'] != '' ): echo ($data['pzname']); ?>  <?php echo (substr($data['pzdate'],0,10)); endif; ?>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</div>


<script>
function print_lsggd(){


    $('#ggdtable').jqprint(
        debug=false,
        media="print2",
        importCSS=true

    );
}
 function qianshou(bmname) {
     var id="<?php echo ($data['id']); ?>";
     $.post(APP + '/Home/Lsggd/qianshou', {
         id: id,
         bmname: bmname
     }, function (data) {

         if (data.status == 1) {
             $('#'+bmname+'_qs').html("<?php echo ($_SESSION['unickname']); ?>"+' '+data.time);


             $.messager.alert('成功', data.msg);
         } else {
             $.messager.alert('错误', data.msg);
         }

     }, 'json');

 }

    function ok_lsggd(id, state) {
        var myDate = new Date();
        // var date=myDate.getFullYear()+'-'+myDate.getMonth()+'-'+myDate.getDate();



var lcArr=['','save','edit','jd','sh','pz'];

        $.post(APP + '/Home/Lsggd/ok', {
            id: id,
            state: state
        }, function (data) {

            if (data.status == 1) {

                $('#'+lcArr[state]+'_show').html("<?php echo ($_SESSION['unickname']); ?>"+'  '+data.time);
                if(state==5){
                    $('#ggdids').html(data.ids)
                }


                $.messager.alert('成功', data.data);
            } else {
                $.messager.alert('错误', data.data);
            }

        }, 'json');
    }

     function out_ggd_excel(id,state){

         if (id) {
             if(state==5)//没有批准
             {
                 window.location.href='/solve/index.php/Home/Lsggd/out/id/'+id+'?number='+Math.random();
             }else{
                 $.messager.confirm('确认','此更改单还没有批准，你确认要导出吗？',function(r){
                     if (r){
                         window.location.href='/solve/index.php/Home/Lsggd/out/id/'+id+'?number='+Math.random();
                     }
                 });
             }

             // 	}
             // });
         } else {
             $.messager.alert("请选择", "该更改单没有编号", "info");
         }
     }

    function excel(id){

                // console.log(data);


     }
</script>